解構賦值 destructuring assignment


Posted by mijouhsieh on 2023-04-16

標準的語法糖
let [a, b, c] = [1, 2, 3]
只要等號兩邊的模式相同 (例如都是 [] 或都是 {}),左邊的變數就會被賦予右邊的對應值。

getRandomNumberArray (count) {
    const number = Array.from(Array(count).keys())
    for(let index = number.length - 1; index > 0 ; index--) {
      let randomIndex = Math.floor(Math.random() * (index + 1))
      ; [number[index], number[randomIndex]] = [number[randomIndex], number[index]]
    }
    return number
  }

#Destructuring assignment #解構賦值







Related Posts

接案平台分享

接案平台分享

2023 Updated Braindumps: Actual Fortinet NSE6_FWB-6.4 Exam Dumps

2023 Updated Braindumps: Actual Fortinet NSE6_FWB-6.4 Exam Dumps

如何用 sequel pro 連到之前 xampp 的資料庫

如何用 sequel pro 連到之前 xampp 的資料庫


Comments